<div class="maintop">
    当前位置：代理链接管理
    <a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($page_current,$page_url)?>" id="btn_refresh" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
</div>
<div class="main-search">
    <table width="100%">
        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="SearchForm" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    <select name="usertype" id="usertype">
                        <option value="">链接类型</option>
                            <option value="">全部链接</option>
                            <option value="1">会员链接</option>
                            <option value="2">代理链接</option>
                    </select>
                    <select name="sortfield" id="sortfield">
                        <option value="">默认</option>
                        <option value="l.actiontimes">创建时间</option>
                        <option value="l.numbers">注册人数</option>
                    </select>
                    <select name="sorttype" id="sorttype">
                        <option value="DESC">倒序</option>
                        <option value="ASC">正序</option>
                    </select>
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    创建日期：从
                    <input id="fromTime" name="fromTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['fromTime']?date('Y-m-d',intval(strtotime($searchdata['fromTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;至
                    <input id="toTime" name="toTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['toTime']?date('Y-m-d',intval(strtotime($searchdata['toTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;&nbsp;
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input type="submit" value="搜索" class="upbutton">
                    <input action="<?=$basepath?>_delete_list" type="button" id="deleteSelectId" value="删除选择" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg">
            <th>No.</th>
            <th>玩家号码</th>
            <th>玩家昵称</th>
            <th>链接类型</th>
            <th>返点</th>
            <th>注册人数</th>
            <th>链接状态</th>
            <th width="130">创建日期</th>
            <th width="45">操作</th>
        </tr>
        <? foreach($datas as $v){ ?>
            <tr<?=(!$v['state']?' class="delete"':'')?>>
                <td><?=$v['id'] ?></td>
                <td><a href="/members/members_list_edit?uid=<?=$v['uid']?>&nickname=<?=$v['nickname']?>" class="colorbox"><?=$v['uno']?></a></td>
                <td><?=$v['nickname']?></td>
                <td><?=(isset($this->usertype[$v['usertype']]) ? $this->usertype[$v['usertype']] : '-')?></td>
                <td><?=$v['rebate']?>%</td>
                <td><?=($v['numbers']>0 ? $v['numbers'] :'-')?></td>
                <td><a href="<?=$basepath?>_state?id=<?=$v['id']?>&<?=$this->page_url($page_current,$page_url)?>&field=state" target="ajax" func="loadpage" class="upbutton state<?=$v['state']?>"><?=($v['state']?'<i class="icon-ok"></i>':'<i class="icon-cancel"></i>')?></a></td>
                <td><?=date('Y-m-d H:i:s',$v['actiontimes'])?></td>
                <td>
                    <a href="javascript:" action="/members/agentlinks_list_edit?id=<?=$v['id']?>" title="编辑 - <?=$v['nickname']?>的推广链接" class="mainFrame button icon-edit"></a>
                </td>
            </tr>
        <? } ?>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){

    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['usertype'])){
            echo '$("#usertype option[value='.$searchdata['usertype'].']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sortfield'])){
            echo '$("#sortfield option[value='.$searchdata['sortfield'].']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sorttype'])){
            echo '$("#sorttype option[value='.$searchdata['sorttype'].']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>
        $(".colorbox").colorbox({ iframe: true,width:"80%",height:"80%" });
    });
</script>
